package cn.dengta.webapp.user.entity;

import java.util.Date;

import cn.dengta.webapp.base.entity.BizEntity;
import cn.dengta.webapp.user.model.CredentialType;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.experimental.Accessors;
import me.codeplayer.util.X;

/**
 * 登录白名单账号。在该白名单内的账号可以使用万能验证码进行登录
 *
 * @author wxm
 * @since 2022/6/29 11:59
 */
@Setter
@Getter
@Accessors(chain = true)
@TableName("dt_white_account")
public class WhiteAccount extends BizEntity {

	/** 账号类型，1=手机号；2=邮箱 */
	protected CredentialType accountType;
	/** 账号 */
	protected String account;
	/** 备注 */
	protected String remark;

	public static final String ID = "id";
	public static final String ACCOUNT_TYPE = "account_type";
	public static final String ACCOUNT = "account";
	public static final String REMARK = "remark";

	public WhiteAccount init(WhiteAccount input, Date now) {
		this.accountType = X.expectNotNull(input.accountType, accountType);
		this.account = X.expectNotEmpty(input.account, account);
		this.remark = X.expectNotEmpty(input.remark, remark);
		super.initTime(now);
		super.init(input.status, input.state);
		return this;
	}

}
